<?php

namespace App\Http\Form;

use Illuminate\Validation\Factory;
use Illuminate\Validation\Validator;

class CustomerValidatorFactory extends Factory
{
    /**
     * Resolve a new Validator instance.
     *
     * @param  array  $data
     * @param  array  $rules
     * @param  array  $messages
     * @param  array  $customAttributes
     * @return Validator
     */
    protected function resolve(array $data, array $rules, array $messages, array $customAttributes): Validator
    {
        if (is_null($this->resolver)) {
            return new CustomerValidator($this->translator, $data, $rules, $messages, $customAttributes);
        }

        return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes);
    }
}
